<script type="text/javascript">
	$(function() {
	    $.fn.dataGridOptions.formSubFun("#form",'/modules/additional/wineCoupons/wineCouponsEdit.html',"修改成功！","修改失败！");
	});
</script>
<style>
.hide{display:none;}
.sForm .ipt{margin-left:155px;}
.sForm .ipt1{margin-bottom:20px;margin-left:155px;}
.sForm .lab{width:139px;}
</style>
<div class="popForm sForm">
    <form id="form"  method="post">
        
    	<div class="formitm">
		     <label class="lab">酒券名称：</label>
		     <div class="ipt">
		     	<input type="text" name="name" class="w200 easyui-validatebox" data-options="required: true" maxlength="10"  value="${wineCoupons.name!}"/>
		     	<b>*</b>
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">是否启用：</label>
		     <div class="ipt">
		     	<input type="radio" id="status" class="xj-hongbao" value="1" name="status"  <#if wineCoupons.status == 1>checked="checked"</#if>>启用
		     	<input type="radio" id="status" class="xn-hongbao" value="0" name="status" <#if wineCoupons.status == 0>checked="checked"</#if>>不启用
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">酒券类型：</label>
		     <div class="ipt">
		     	<input type="radio" id="type" class="xj-hongbao" value="1" name="type"  <#if wineCoupons.type == 1>checked="checked"</#if>>现金酒券
		     	<!-- <input type="radio" id="type" class="xn-hongbao" value="2" name="type"  <#if wineCoupons.type == 2>checked="checked"</#if>>虚拟酒券 -->
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">发放方式：</label>
		     <div class="ipt">
		     		<select name="payType" id="payType" onchange="showPayType()">
						<option value="1" <#if wineCoupons.payType == 1>selected="selected"</#if>>固定金额</option>
						<!--  
						<option value="2" <#if wineCoupons.payType == 2>selected="selected"</#if>>固定比率</option>
						<option value="3"	<#if wineCoupons.payType == 3>selected="selected"</#if>>区间金额</option>
						<option value="4"	<#if wineCoupons.payType == 4>selected="selected"</#if>>区间比率</option>
						-->
					</select>
		     </div>
		</div>
		<div class="formitm hongbao-money">
		     <label class="lab">酒券金额：</label>
		     <div class="ipt">
		     	<input type="text" name="amount" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.amount!0}"/>元
		     </div>
		</div>
		<div class="formitm hide hongbao-rate">
		     <label class="lab">金额比率：</label>
		     <div class="ipt">
		     	<input type="text" name="rate" id="rate" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.rate!0}"/>%
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">标期限：</label>
		     <div class="ipt">
		     	<input type="text" name="timeLimit" id="day" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.timeLimit!}"/>月
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">最小投标金额(含)：</label>
		     <div class="ipt">
		     	<input type="text" name="minTenderAmount" id="day" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.minTenderAmount!}"/>元
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">最大投标金额：</label>
		     <div class="ipt">
		     	<input type="text" name="maxTenderAmount" id="day" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.maxTenderAmount!}"/>元
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">数量：</label>
		     <div class="ipt">
		     	<input type="text" name="number" id="day" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.number!}"/>张
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">有效期：</label>
		     <div class="ipt">
		     	<input type="text" name="validDay" id="day" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.validDay!0}"/>天
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">酒券库存：</label>
		     <div class="ipt">
		     	<input type="text" name="total" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.total!0}"/>张
		     </div>
		</div>
		<div class="formitm hide min_amount">
		     <label class="lab">最小金额：</label>
		     <div class="ipt">
		     	<input type="text" name="minAmount" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.minAmount!0}"/>元
		     </div>
		</div>
		<div class="formitm hide max_amount">
		     <label class="lab">最大金额：</label>
		     <div class="ipt">
		     	<input type="text" name="maxAmount" class="w200 easyui-validatebox"  maxlength="10" value="${wineCoupons.maxAmount!0}"/>元
		     </div>
		</div>
		<div class="formitm" id="sectionMoney">
		<#if wineCoupons.payType == 3 && attachedList??>
		<#list attachedList as item>
		<ul class="sectionMoneyList">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7" value="${item.min!0}">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7" value="${item.max!0}">元</div>
	
			</li>
			<li>
				<label class="lab">酒券金额：</label>
				<div class="ipt"><input type="text" name="payAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7" value="${item.amount!0}">元</div>
			</li>
			<#if item_index gt 0>
			<li><a href="javascript:;" class="removeList" title="删除">-</a></li>
			</#if>
			</ul>
			</#list>
			<#else>
			<ul class="sectionMoneyList">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">酒券金额：</label>
				<div class="ipt"><input type="text" name="payAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
		</ul>
		</#if>
		<!--	S  删除列表隐藏域 -->
		<ul class="sectionMoneyList" style="display:none;">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">酒券金额：</label>
				<div class="ipt"><input type="text" name="payAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			<li><a href="javascript:;" class="removeList" title="删除">-</a></li>
		</ul>
		<!--	E  删除列表隐藏域 -->
		<a  href="javascript:;" class="addList" title="添加">+</a>		
		</div>
		
		<div class="formitm" id="sectionRate">
		<#if wineCoupons.payType == 4 && attachedList??>
		<#list attachedList as item>
		<ul class="sectionRateList">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7" value="${item.min!0}">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7" value="${item.max!0}">元</div>
	
			</li>
			<li>
				<label class="lab">酒券比率：</label>
				<div class="ipt"><input type="text" name="payRate" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7" value="${item.rate!0}">%</div>
			</li>
			<#if item_index gt 0>
			<li><a href="javascript:;" class="removeList" title="删除">-</a></li>
			</#if>
		</ul>
			</#list>
			<#else>
			<ul class="sectionRateList">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">酒券比率：</label>
				<div class="ipt"><input type="text" name="payRate" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">%</div>
			</li>
		</ul>
		</#if>
		<!--	S  删除列表隐藏域 -->
		<ul class="sectionRateList" style="display:none;">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			<li>
				<label class="lab">酒券比率：</label>
				<div class="ipt"><input type="text" name="payRate" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">%</div>
			</li>
			<li><a href="javascript:;" class="removeList" title="删除">-</a></li>
		</ul>
		<!--	E  删除列表隐藏域 -->
		<a  href="javascript:;" class="addList" title="添加">+</a>		
	</div>
	<div class="formitm">
	     <label class="lab">酒券描述：</label>
	     <div class="ipt">
	     	<textarea rows="3" cols="50" maxlength="250" name="description">${wineCoupons.description!}</textarea>
	     </div>
	</div>
	<div class="formitm">
	     <label class="lab">添加时间：</label>
	     <div class="ipt">
	     	${wineCoupons.addTime?string('yyyy-MM-dd hh:mm:ss')}
	     </div>
	</div>
	<div class="formitm">
	     <label class="lab">添加IP：</label>
	     <div class="ipt">
	     	${wineCoupons.addIp!}
	     </div>
	</div>
	<input type="hidden" name="addTime" value="${wineCoupons.addTime?string('yyyy-MM-dd hh:mm:ss')}">
	<input type="hidden" name="addIp" value="${wineCoupons.addIp!}">
	<input type="hidden" name="id" value="${wineCoupons.id!}">
	<input type="hidden" name="issueNum" value="${wineCoupons.issueNum?c}"/>
	</form>
</div>
<script type="text/javascript">
	function showPayType(){
		var value = $("#payType").val();
		if(value==1){//固定金额
			$(".hongbao-rate").hide();
			$(".hongbao-money").show();
			$(".max_amount").hide();
			$(".min_amount").hide();
			$("#sectionMoney").hide();
			$("#sectionRate").hide();
			$("#sectionMoney input").attr("disabled",true);
			$("#sectionRate input").attr("disabled",true);
		}
		if(value==2){//固定比率
			$(".hongbao-rate").show();
			$(".hongbao-money").hide();
			$(".max_amount").show();
			$(".min_amount").show();
			$("#sectionMoney").hide();
			$("#sectionRate").hide();
			$("#sectionMoney input").attr("disabled",true);
			$("#sectionRate input").attr("disabled",true);
		}
		if(value==3){//区间金额
			$(".hongbao-rate").hide();
			$(".hongbao-money").hide();
			$(".max_amount").hide();
			$(".min_amount").hide();
			$("#sectionMoney").show();
			$("#sectionRate").hide();
			$("#sectionMoney input").attr("disabled",false);
			$("#sectionRate input").attr("disabled",true);
		}
		if(value==4){//区间比率
			$(".hongbao-rate").hide();
			$(".hongbao-money").hide();
			$(".max_amount").show();
			$(".min_amount").show();
			$("#sectionMoney").hide();
			$("#sectionRate").show();
			$("#sectionMoney input").attr("disabled",true);
			$("#sectionRate input").attr("disabled",false);
		}
	}
	
	showPayType();
	
	//区间金额
	var sectionMoneyStr = $("#sectionMoney .sectionMoneyList:last").prop("outerHTML");
	
	$("#sectionMoney .addList").click(function(){
		$("#sectionMoney .sectionMoneyList:last").css("display","block");
		$(this).before(sectionMoneyStr);
		$("#sectionMoney input").attr("disabled",false);
	});
	$("#sectionMoney .removeList").live("click",function(){	//	给动态生成的元素添加事件，应使用live
		 $(this).parent().parent().remove();
	});
	
	//区间比例
	var sectionRateStr = $("#sectionRate .sectionRateList:last").prop("outerHTML");
	
	$("#sectionRate .addList").click(function(){
		$("#sectionRate .sectionRateList:last").css("display","block");
		$(this).before(sectionRateStr);
		$("#sectionRate input").attr("disabled",false);
	});
	$("#sectionRate .removeList").live("click",function(){	//	给动态生成的元素添加事件，应使用live
		 $(this).parent().parent().remove();
	});
	</script>
